<!-- 我的基础 -->

<template>
  <WebShow path="roadway">
    <EasyRow flex>
      <SecureVideo :id="videoId" :visible="detailVisible" />
      <!-- <SecureVideo src="https://jrjpic.jrjkg.com.cn/churukou.mp4" /> -->

      <div>
        <ShowDict label="车道类型" bind="roadwayType" :dict="CORE.DICT.DIRECTION" suffix="口" />
        <ShowStatus label="道闸状态" bind="gateStatus" :dict="CORE.DICT.STATUS_ROADWAY" />
        <ShowSlot label="道闸控制">
          <BtnPrimary v-for="item in CONTROL" :key="item[0]" :title="item[1]" @click="toControl(item)" />
        </ShowSlot>
      </div>
    </EasyRow>
  </WebShow>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyBase',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb('roadway')],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('@admin/views/Secure/components', true, /vue$/)),

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: {
    /**
     * 控制字典 (命令编号，名称，对应状态)
     */
    CONTROL: () => [
      [2, '开闸', 1],
      [1, '关闸', 2],
      [3, '常开', -1],
    ],

    /**
     * 视频 ID
     */
    videoId() {
      const { videoDevice } = this.one
      return CORE.isEmpty(videoDevice) ? '' : videoDevice[0].deviceId
    },

    /**
     * 详情弹窗可见
     */
    detailVisible() {
      const detail = CORE.componentParent(this, 'DetailParking')
      return detail ? detail.detailVisible : false
    },
  },

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 道闸反控
     */
    toControl([command, TIP]) {
      CORE.merge(this.one, { command, TIP })
      this.startEdit()
    },
  },
}
</script>
